package com.example.mapper;

import com.example.entity.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

    // 通用查询方法
    List<Comment> selectAll(Comment comment);

    // 带关联表的查询
    List<Comment> selectByWrittenId(Integer writtenId);

    int insert(Comment comment);

    // 更新方法
    int updateById(Comment comment);

    @Delete("delete * from `comment` where id = #{id}")
    void deleteById(Integer id);

    @Select("select * from `comment` where id = #{id}")
    List<Comment> selectChildren(Integer id);

/*    @Select("select * from `comment` where user_id = #{userId}")*/
    List<Comment> selectByUserId(Integer userId);
}